package org.slicerj;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
import org.slicerj.core.SlicingCiterion;

/**
 * The activator class controls the plug-in life cycle
 */
public class SlicerJActivator extends AbstractUIPlugin {

	// The plug-in ID
	public static final String PLUGIN_ID = "org.slicerj"; //$NON-NLS-1$

	// The shared instance
	private static SlicerJActivator plugin;

	private SlicingCiterion slicingCiterion;

	private IProject project;

	/**
	 * The constructor
	 */
	public SlicerJActivator() {
		slicingCiterion = new SlicingCiterion();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
	 * )
	 */
	public void start(BundleContext context) throws Exception {
		super.start(context);
		plugin = this;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
	 * )
	 */
	public void stop(BundleContext context) throws Exception {
		plugin = null;
		super.stop(context);
	}

	/**
	 * Returns the shared instance
	 * 
	 * @return the shared instance
	 */
	public static SlicerJActivator getDefault() {
		return plugin;
	}

	public void setSlicingPoint(int slicigPoint) {
		slicingCiterion.setSlicingPoint(slicigPoint);
	}

	public void addSliceVariables(String variable) {
		slicingCiterion.addVariable(variable);
	}

	public SlicingCiterion getSlicingCiterion() {
		return slicingCiterion;
	}

	public void setCurrentProject(IProject project) {
		this.project = project;		
	}

	public IProject getCurrentProject() {
		return project;
	}
	
	public IPath getWorkspacePath(){
		return project.getWorkspace().getRoot().getLocation();
	}

}
